package graph_viewer.drawer;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Font;
import java.awt.FontMetrics;

import graph_viewer.structure.Node;
import graph_viewer.structure.Node_Position;
import graph_viewer.structure.Visual_Component;

import graph_viewer.util.*;

/**
	Define method to draw a node, the drawing is done by Node_Drawer_Handler in subclasses.
*/
public class Basic_Node_Drawer extends Node_Drawer{
	boolean has_label, has_DOI;

	public Basic_Node_Drawer(){
		set_has_DOI( false );
		set_has_label( false );
	}

	public Basic_Node_Drawer( boolean has_label, boolean has_DOI ){
		set_has_DOI( has_DOI );
		set_has_label( has_label );
	}
	
	public Basic_Node_Drawer( boolean has_label ){
		set_has_DOI( false );
		set_has_label( has_label );
	}

	public void set_has_DOI( boolean has ){
		has_DOI		= has;
	}

	public void set_has_label( boolean has ){
		has_label	= has;
	}
	
	public boolean get_has_DOI( ){
		return has_DOI;
	}

	public boolean get_has_label(  ){
		return has_label;
	}
	protected void draw_node( Node node, final Graphics2D g, int k ){
	//do nothing
	}
	
	protected void draw_node_label( Node node, final Graphics2D g ){	
		if ( !get_has_label() ){
			return;
		}
		
		int[]	location	= node.get_position().find_location();
		String label	=Drawer_Util.get_displayed_label( node );

		g.setColor( Color.black );
		g.drawString( label, location[0]  + 1 , location[1] + node.get_position().get_height() - 1 ); // +1 to set the margin
	}	
}